﻿/**************************************************************************************************

	NSurvey - The web survey and form engine
	Copyright (c) 2004, Thomas Zumbrunn. (http://www.nsurvey.org)

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

************************************************************************************************/
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Votations.NSurvey.Resources;
using Votations.NSurvey.WebControls.UI;
using Votations.NSurvey.WebAdmin.UserControls;

namespace Votations.NSurvey.WebAdmin
{
    /// <summary>
    /// Polls the mailing status to see if 
    /// its finished
    /// </summary>
    public partial class MailingPollStatus : PageBase
    {
        public override string ActionCode
        {
            get
            {
                return "105";//调查邮件
            }
        }

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Check if the task has been finished
            object obj = SyncDataStore.GetRecords(Session.SessionID);
            if (obj != null)
            {
                Response.Write("<center>" + GetPageResource("AllInvitationSendMessage") + "</center>");
                ProgressBar.Visible = false;
                SyncDataStore.Remove(Session.SessionID);
                SyncDataStore.Remove(Session.SessionID + ":" + "Progress");
            }
            else
            {
                object error = SyncDataStore.GetRecords(Session.SessionID + ":" + "Error");
                if (error != null)
                {
                    throw (Exception)error;
                }
                else
                {
                    // Retrieve the current progress of the task
                    object mailingProgress = SyncDataStore.GetRecords(Session.SessionID + ":" + "Progress");
                    if (mailingProgress != null)
                    {
                        ProgressBar.Progress = int.Parse(mailingProgress.ToString());
                    }
                    else
                    {
                        ProgressBar.Progress = 0;
                    }
                    ProgressBar.TableWidth = Unit.Pixel(400);
                    Response.AddHeader("Refresh", "2");
                }
            }
        }

    
    }

}
